<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />

    <title>Document</title>
</head>

<body>
    <div id="friends">
        分享
    </div>
    <script>
        document.getElementById('friends').addEventListener('click', function () {
            var shares;
            mui.plusReady(function () {
                plus.share.getServices(function (list) {
                    for (var i = 0; i < list.length; i++) {
                        if (list[i].authenticated) {
                            shares = list[i];
                        }
                    }

                    if (shares != undefined) {
                        var msg = {
                            type: 'image',
                            pictures: ["_www/logo.png"], //这里的pictures是要分享的图片 该图片放在项目根目录下
                            extra: {
                                scene: "WXSceneSession"
                            }
                        };
                        shares.send(msg, function (success) {
                            mui.toast("转发成功!");
                        }, function (error) {
                            //mui.toast("转发失败"+JSON.stringify(error));
                            console.log(JSON.stringify(error))
                        });
                    }
                }, function (e) {
                    alert("获取分享服务列表失败：" + e.message);
                });

            });
        });
    </script>
</body>

</html>